package com.zr.planClass.service.impl;

import com.zr.planClass.mapper.BaoJiaMapper;
import com.zr.planClass.model.baojia.BaoJiaFenYeFanHUiVo;
import com.zr.planClass.model.baojia.BaoJiaVo;
import com.zr.planClass.service.BaoJiaService;
import com.zr.util.AllRecords;
import com.zr.util.ResultBuilderVo;
import com.zr.util.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by 非常狂躁的猪 on 2019/12/31.
 */
@Service
public class BaoJiaServiceImpl implements BaoJiaService {

    @Autowired
    private BaoJiaMapper baoJiaMapper;

    @Override
    public ResultVo queryAll(BaoJiaVo baoJiaVo) {
        List<BaoJiaFenYeFanHUiVo> list = baoJiaMapper.queryAll(baoJiaVo);
        Integer count = baoJiaMapper.queryAllCount(baoJiaVo);

        AllRecords allRecords = new AllRecords();
        allRecords.setDataList(list);
        allRecords.setPageSize(baoJiaVo.getPageSize());
        allRecords.setPageIndex(baoJiaVo.getPageIndex());
        allRecords.setTotalNumber(count); //总共的条数
        allRecords.resetTotalNumber(count); //计算总页数

        return ResultBuilderVo.success(allRecords);
    }

}
